/**
 * SceneGame_Camera
 * 	@brief  Moves the camera along the player
 * 	@author Bruno Miguel de Oliveira Tamer <bmotamer@gmail.com>
 */

using UnityEngine;

public class SceneGame_Camera : MonoBehaviour
{
	
	public  SceneGame_Player Target;
	private float            _ZDistance;
	
	public void Start()
	{
		_ZDistance = Target.transform.position.z - transform.position.z;
	}
	
	public void Update()
	{
		float abs = Mathf.Abs(Target.Bounds.height) - Mathf.Abs(Target.Bounds.y);
		transform.position = new Vector3(
			transform.position.x,
			transform.position.y,
			Target.transform.position.z - (2 * abs + Target.Offset.y) - 0.5f * _ZDistance
		);
	}
	
}